<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Perfiles</title>
    </h:head>
    <h:body>
        <p:growl id="msgPE" showDetail="true" 
                     life="9000" autoUpdate="true"/>
        <h:panelGrid style="margin: 0 auto">
            <p:outputLabel value="Editar Perfiles" style="color: #2480BC; font-weight: bold; font-size: 1.3em;"/>
        </h:panelGrid>
        
        <p:outputLabel value="Nombre del Perfil: " style="color: #2480BC; font-weight: bold; font-size: 1.3em;"/>
        <p:selectOneMenu id="prof" value="#{editProfileBean.name}" >  
            <f:selectItem itemLabel="Selecionar Perfil" itemValue="" />  
            <f:selectItems value="#{editProfileBean.profiles}" /> 
            <p:ajax    listener="#{editProfileBean.handleCityChange}" 
                        update="dataTableProfil"/>
        </p:selectOneMenu>
        
        <p:dataTable id="dataTableProfil" var="perfil" 
                value="#{editProfileBean.tableModel}"
                paginator="true" rows="8"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                rowsPerPageTemplate="6,8,10,12"
                selection="#{editProfileBean.profile}"
                selectionMode="single"
                rowKey="#{perfil.profile}"
                editable ="true"
                >
            <p:ajax event="rowEdit" listener="#{editProfileBean.onEdit}" />
            <p:ajax event="rowEditCancel" listener="#{editProfileBean.onCancel}"  />

            <p:column headerText="Perfil">  
                <h:outputText value="#{perfil.profile}" />  
            </p:column>  

            <p:column headerText="Nombre del recurso" style="text-align: center">  
                <h:outputText value="#{perfil.resourceName}" />
            </p:column>  

            <p:column headerText="Recurso" style="text-align: center">  
                <h:outputText value="#{perfil.resource}" />
            </p:column>

            <p:column headerText="Limite" style="text-align: center">  
                <p:cellEditor>
                    <f:facet name="output" >
                        <h:outputText value="#{perfil.limit}" />
                    </f:facet>
                    <f:facet name="input" >
                        <p:inputText value="#{perfil.limit}"
                                     style=" width: 100%" />
                    </f:facet>
                </p:cellEditor>

            </p:column>

            <p:column headerText="Edici&oacute;n" 
                      styleClass="ui-editable-column-options" 
                      style="text-align: center"> 

                        <p:rowEditor >
                        </p:rowEditor>

            </p:column>  

        </p:dataTable> 
        <p:commandButton value="Eliminar"  ajax="false"
                         action="#{editProfileBean.delete}" 
                         style="margin-top:5px"
                         update="msgPE"/>  
    </h:body>
</html>
